package com.gict.antifraudback.controller.front.magnet;

import com.gict.antifraudback.entity.MagnetFile;
import com.gict.antifraudback.result.ResultEnum;
import com.gict.antifraudback.result.ResultView;
import com.gict.antifraudback.utils.UserThreadLocal;
import com.gict.antifraudback.utils.magnet.BTLMMagnet;
import com.gict.antifraudback.utils.magnet.IMagnet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 磁力控制器
 */
@RestController
@Slf4j
@RequestMapping("/mapi/magnet")
public class FrontMagnetController {

    @Autowired
    private BTLMMagnet btlmMagnet;

    @GetMapping("/queryList")
    public ResultView userInfo(String keyword) {
        if (ObjectUtils.isEmpty(keyword)) {
            return ResultView.error(ResultEnum.CODE_2);
        }
        List<MagnetFile> magnetFile = btlmMagnet.listMagnetByKeyWord(keyword, 1);
        for (MagnetFile file : magnetFile) {
            System.out.println(file);
        }
        return ResultView.ok(magnetFile);
    }

}
